package com.soft.service;

import java.util.List;

import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.util.Assert;

import com.soft.entity.Goods;

@SpringBootTest
public class GoodsServiceTest {
@Autowired
private GoodsService goodsService;
@Test
public void queryAllTest() {
	List<Goods> goodsList = goodsService.queryAll();
	Assert.notEmpty(goodsList, "为空");
	Assert.isTrue(goodsList.size()>0, "数据有值");
//	for(int i=0;i<moneyList.size();i++) {
//		System.out.println(moneyList.get(i).getNote());
//	}
}
   @Test
	public void queryBynameTest() {
		List<Goods> goodslist=goodsService.queryByname("aa");
		Assert.isTrue(goodslist.size()==1, "根据name进行查询结果的数据不对");
	}
   @Test
   public void insertOneTest() {
	   int num =goodsService.insertOne("电视","5000");
	   Assert.isTrue(num==1,"增加数据错误");
   }
   @Test
   public void deleteTest() {
	   int num =goodsService.deleteById((long)2);
	   Assert.isTrue(num==1,"删除数据错误" );
   }
   @Test
   public void updateTest() {
	   int num =goodsService.updateById((long)2,"电视","5000");
	   Assert.isTrue(num==1,"修改数据错误");
   }
   //@Test
   public void queryByGoodslocNameTest() {
	   List<Goods> goodslist=goodsService.queryByGoodslocName("江南厂");
	   Assert.isTrue(goodslist.size()==2,"查询错误");
   }
   @Test
   public void updateGoodsTest() {
	   int num = goodsService.updateGoods("音响","200","江南厂");
	   Assert.isTrue(num==1,"修改价格错误");
   }
}
